package com.example.xianji.activity;

import android.os.Bundle;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;

import com.example.xianji.Contant;
import com.example.xianji.R;
import com.example.xianji.constant.Constant;
import com.example.xianji.utils.sp.PreferenceEngine;

public class Main_FuWu_GuanLiActivity extends Activity implements OnClickListener {
    private RelativeLayout fuwu_guanli_back;
    //    private SharedPreferences sp;
//    private Editor ed;
    private RelativeLayout relativelayout_my_fuwu_collection, relative_layout_mysend_fuwu,
            relativelayout_my_fuwu_liuyan, relativelayout_send_fuwu, relative_layout_sales_fuwu, relativelayout_my_receiver_fuwu_liuyan;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
        setContentView(R.layout.activity_main__fu_wu__guan_li);
        //MyApplication.getInstance().addActivity(this);
//        sp = getSharedPreferences("text", MODE_PRIVATE);
//        ed = sp.edit();

        fuwu_guanli_back = (RelativeLayout) findViewById(R.id.fuwu_relative_guanli_back);
        relativelayout_send_fuwu = (RelativeLayout) findViewById(R.id.relativelayout_send_fuwu);
        relativelayout_my_fuwu_collection = (RelativeLayout) findViewById(R.id.relativelayout_my_fuwu_collection);
        relativelayout_my_fuwu_liuyan = (RelativeLayout) findViewById(R.id.relativelayout_my_fuwu_liuyan);
        relative_layout_sales_fuwu = (RelativeLayout) findViewById(R.id.relative_layout_sales_fuwu);
        relative_layout_mysend_fuwu = (RelativeLayout) findViewById(R.id.relative_layout_mysend_fuwu);
        relativelayout_my_receiver_fuwu_liuyan = (RelativeLayout) findViewById(R.id.relativelayout_my_receiver_fuwu_liuyan);

        //个人用户
        if (PreferenceEngine.getInstance().getString(Constant.SP.NAME, Constant.SP.KEY_XIANJI_TYPE, "").equals("FP") ||
                PreferenceEngine.getInstance().getString(Constant.SP.NAME, Constant.SP.KEY_XIANJI_TYPE, "").equals("AP")) {
//        if (sp.getString("xianji_type", "").equals("FP") || sp.getString("xianji_type", "").equals("AP")) {
            relative_layout_sales_fuwu.setVisibility(View.GONE);
            relative_layout_mysend_fuwu.setVisibility(View.GONE);
            relativelayout_my_receiver_fuwu_liuyan.setVisibility(View.GONE);
            relativelayout_send_fuwu.setVisibility(View.GONE);
        } else {
            //企业用户
            //relative_layout_sales_fuwu.setVisibility(View.VISIBLE);
            relative_layout_mysend_fuwu.setVisibility(View.VISIBLE);
            relativelayout_my_receiver_fuwu_liuyan.setVisibility(View.VISIBLE);
            relativelayout_send_fuwu.setVisibility(View.VISIBLE);


        }
        fuwu_guanli_back.setOnClickListener(this);

        relativelayout_send_fuwu.setOnClickListener(this);
        relativelayout_my_fuwu_collection.setOnClickListener(this);
        relativelayout_my_fuwu_liuyan.setOnClickListener(this);
        relative_layout_sales_fuwu.setOnClickListener(this);
        relative_layout_mysend_fuwu.setOnClickListener(this);
        relativelayout_my_receiver_fuwu_liuyan.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.fuwu_relative_guanli_back) {

            this.finish();
        } else if (v.getId() == R.id.relative_layout_mysend_fuwu) {
            //我发布的服务
            startActivity(new Intent(Main_FuWu_GuanLiActivity.this, Main_My_ServiceActivity.class));

        } else if (v.getId() == R.id.relativelayout_send_fuwu) {

            startActivity(new Intent(Main_FuWu_GuanLiActivity.this, Main_geren_send_fuwuActivity.class));
        } else if (v.getId() == R.id.relativelayout_my_fuwu_collection) {
            Intent intent = new Intent(this, Main_My_CollectionActivity.class);
            intent.putExtra("collection_type", "detail");//需求
            startActivity(intent);
        } else if (v.getId() == R.id.relativelayout_my_fuwu_liuyan) {

            Intent intent = new Intent(Main_FuWu_GuanLiActivity.this, Main_My_product_liuyanActivity.class);
            intent.putExtra("liuyan_comeFrom", Contant.come_from_my_service_liuyan);
            startActivity(intent);
        } else if (v.getId() == R.id.relativelayout_my_receiver_fuwu_liuyan) {
            //我收到的服务留言
            Intent intent = new Intent(Main_FuWu_GuanLiActivity.this, Main_My_product_liuyanActivity.class);
            intent.putExtra("liuyan_comeFrom", Contant.come_from_my_receiver_fuwu_liuyan);
            startActivity(intent);
        }
    }


}
